<?php

if (!defined('INDEX')) exit;
###########################################################################################
// Table names (leave blank for table which not use)
$tbl["cat"] = "";
$tbl["content"] = "motor";

// Start class
require("core/class_start.inc.php");

###########################################################################################
//$jcas->draw_input(input_type, field_name, width, height, default_value, check_duplicated)
switch (@$_GET['p'])
{
	
	// Generate form add content
	case "add_content":
		$mdl_form = array(
            'City <font color=red>*</font>' => $jcas->draw_select_cat("city",'city_id','name',1,0,'id'),
            'Loại' => $jcas->draw_input('select','type','400px',0,$arrType,0),
            'Năm sản xuất' => $jcas->draw_input('text','year','400px',0,'',0),
			'Số km sử dụng' => $jcas->draw_input('text','kms','400px',0,'',0),
			'Giá' => $jcas->draw_input('text','price','400px',0,'',0),
			'Giá từ' => $jcas->draw_input('text','price_from','400px',0,'',0),
			'Giá đến' => $jcas->draw_input('text','price_to','400px',0,'',0),
			'Description' => $jcas->draw_input('textarea','desc','70%','80px','',0),
            //'Accessories' => $jcas->draw_input('textarea','accessories','70%','80px','',0),
		);
	break;
	
	// Generate form edit content
	case "edit_content":
		$mdl_form = array(
            'City <font color=red>*</font>' => $jcas->draw_select_cat("city",'city_id','name',1,0,'id'),
            'Loại' => $jcas->draw_select('type',$arrType),
			'Thương hiệu' => $jcas->draw_select_cat_motor('manufacture','manu_id','name',0,'id',1),
			'Thương hiệu khác' => $jcas->draw_input('text','manu_diffirent','400px',0,'',0),
			'Model' => $jcas->draw_select_cat_motor('model','model_id','name',0,'id',2),
			'Model khác' => $jcas->draw_input('text','model_diffirent','400px',0,'',0),
            'Năm sản xuất' => $jcas->draw_input('text','year','400px',0,'',0),
			'Số km sử dụng' => $jcas->draw_input('text','kms','400px',0,'',0),
			'Giá' => $jcas->draw_input('text','price','400px',0,'',0),
			'Giá từ' => $jcas->draw_input('text','price_from','400px',0,'',0),
			'Giá đến' => $jcas->draw_input('text','price_to','400px',0,'',0),
			'Description' => $jcas->draw_input('textarea','desc','70%','80px','',0),
            //'Accessories' => $jcas->draw_input('textarea','accessories','70%','80px','',0),
		);
	break;
	
	// Generate view content
	case "view_content":
		$mdl_form = "";
	break;
}
###########################################################################################
// Records per page
$mdl_cfg["content_per_page"] = 20;

// Module description (displayed on the top page)
$mdl_cfg['module_description'] = 'Quản lý tin đăng bán xe';

// Head title (leave blank for default)
$mdl_cfg['head_title'] = '';

// Fields that require user to type in (seperated by comma)
$mdl_cfg['required_fields'] = "";

// Search in fields (each field in array)
$mdl_cfg['search_fields'] = array(
	//'field name' => 'display text',
	'id' => 'Id',

);

// Sort by fields (Ascending)
$mdl_cfg['sort_fields'] = array(
	//'field name' => 'display text',
	'default' => 'Mặc định',	
	'created_time' => 'Ngày tạo',
);

// Display cat options
$mdl_cfg['cat_options'] = '';

// Display content options
$mdl_cfg['content_options'] = array(
	//'content_option&content_field&content_value' => 'display text',
	'content_option=default' => $lang['display_default'],
	'content_option=1&content_field=active&content_value=0' => $lang['display_inactive_items'],
	'content_option=2&content_field=active&content_value=1' => $lang['display_active_items'],
    'content_option=3&content_field=type&content_value=0' => $arrType[0],
    'content_option=4&content_field=type&content_value=1' => $arrType[1]
);
$mdl_cfg['tbl_alias'] = 'motor.';
$mdl_sql['show_content'] = 'SELECT SQL_CALC_FOUND_ROWS
                            motor.id,
                            motor.alias,
                            motor.user_id,
                            motor.manu_id,
                            motor.model_id,
                            motor.city_id,
                            motor.style_id,
                            motor.type,
                            motor.`year`,
                            motor.kms,
                            motor.`desc`,
                            motor.accessories,
                            motor.image,
                            motor.image1,
                            motor.image2,
                            motor.price,
                            motor.price_from,
                            motor.price_to,
                            motor.premium,
                            motor.cat_id,
                            motor.lang_id,
                            motor.admin_id,
                            motor.sort,
                            motor.created_by,
                            motor.created_time,
                            motor.updated_by,
                            motor.updated_time,
                            motor.active,
                            users.first_name,
                            users.last_name,
                            users.email,
                            city.`name`
                            FROM
                            motor
                            INNER JOIN users ON motor.user_id = users.id
                            INNER JOIN city ON motor.city_id = city.id
                            WHERE 1';
if (get('manu_id')){
    $mdl_sql['show_content'] .= ' AND motor.manu_id='.get('manu_id');
}                            
?>